<?php
namespace app\app\controller\v2;
use app\app\Appbase;

class Freight extends Appbase 
{
	
	/**
	* 获取指定店铺的运费模板列表
	* /app/v2/Freight/getList
	* 需要登录 
	* @is_need_login true
	* @method all
	*/
	public function getList(){
		try {
			$result = model('ShopFreight')->getList( request()->shopId );
			return $this->ReSucess($result);	
		} catch (\Exception $e) {
			return $this->ReError($e->getMessage());	
		}
	}
	
	/**
	* 为当前店铺添加或更新运费模板
	* /app/v2/Freight/addAndUpdate
	* 需要登录 
	* @is_need_login true
	* @method post
	*/
	public function addAndUpdate(){
		$param = request() ->post();
		$param['shop_id'] = request()->shopId;
		try {
			$result = model('ShopFreight')->addAndUpdate($param);
			if($result === false){
				return $this->ReError( model('ShopFreight')->errorInfo );
			}
			return $this->ReSucess($result);	
		} catch (\Exception $e) {
			return $this->ReError($e->getMessage());	
		}
	}
	
	/**
	* 删除模板
	* /app/v2/Freight/del
	* 需要登录 
	* @is_need_login true
	* @method all
	*/
	public function del($id){
		try {
			$result = model('ShopFreight')->del($id);
			return $this->ReSucess();	
		} catch (\Exception $e) {
			return $this->ReError($e->getMessage());	
		}
	}
	
}



